home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-21 | 1.6 KB | 66 lines | [TEXT/CWIE] |
- //Copyright (c) 1997 Aidan Cully
- //All rights reserved
-
- #include "EquNew.h"
- #include <math.h>
- #include "CLStrStuff.h"
- #include "Misc.h"
- #include "LMath.h"
-
- TEquNew::TEquNew( TLayoutBranch *super, MActionHandler *superHandler, Boolean hasDD,
- TPlane *nplane, TConic *conic ):
- TDocContent( super, hasDD, superHandler, nplane )
- {
- mConic= conic;
- }
-
- SInt8 TEquNew::DXDivY( int x, int y, unsigned char *num, unsigned char *den )
- {
- MoveTo( x, y );
- DrawString( num );
- MoveTo( x, y+3 );
- Line( 60, 0 );
- MoveTo( x, y+12+6 );
- DrawString( den );
- }
-
- void TEquNew::DrawSelf( TDrawSlate *gr )
- {
- EraseRect( &GetLocalRect() );
- float a,b,npang;
- int dec,sign,deccount;
- Str32 astr,bstr,cstr,ystr;
-
- MoveTo(20,20);
- npang = fmod(mPlane->GetAngle(),180);
- if (fabs(npang)<0.001) {
- a = mPlane->GetDistance()*mPlane->GetDistance();
- StrCpy( astr, gcvt(a,5) );
- DrawString("\px^2 + y^2 =");
- DrawString(astr);
- } else if ((npang == 45) || (npang == 135)) {
- a = 4*mPlane->GetDistance()/2;
- if( npang == 135 )
- a = -a;
- DrawString("\px^2 = ");
- StrCpy( astr, gcvt( a, 5 ) );
- DrawString(astr);
- DrawString("\py");
- } else if ((npang < 45) || (npang > 135)) {
- } else {
- a = mPlane->GetDistance()/mPlane->GetSinAngle();
- a = a*a;
- b = mPlane->GetDistance()*tan((45-mPlane->GetAngle())*M_PI/180);
- b += (mPlane->GetDistance()*tan((45+mPlane->GetAngle())*M_PI/180));
- b /= 2;
- b = b*b;
- StrCpy( astr, gcvt( a, 5 ) );
- DXDivY( 20, 20, "\py^2", astr );
- StrCpy( bstr, gcvt( b, 5 ) );
- DXDivY( 100, 20, "\px^2", bstr );
- MoveTo( 90, 28 );
- DrawString( "\p-" );
- Move(74,0);
- DrawString("\p= 1");
- }
- }